home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 118 / cd-rom 118.iso / aplic / open / openofficeorg2.cab / ooo2wordml_text.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-01-31  |  72.1 KB  |  1,177 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.    The Contents of this file are made available subject to the terms of
  4.    either of the following licenses
  5.  
  6.           - GNU Lesser General Public License Version 2.1
  7.           - Sun Industry Standards Source License Version 1.1
  8.  
  9.    Sun Microsystems Inc., October, 2000
  10.  
  11.    GNU Lesser General Public License Version 2.1
  12.    =============================================
  13.    Copyright 2000 by Sun Microsystems, Inc.
  14.    901 San Antonio Road, Palo Alto, CA 94303, USA
  15.  
  16.    This library is free software; you can redistribute it and/or
  17.    modify it under the terms of the GNU Lesser General Public
  18.    License version 2.1, as published by the Free Software Foundation.
  19.  
  20.    This library is distributed in the hope that it will be useful,
  21.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  23.    Lesser General Public License for more details.
  24.  
  25.    You should have received a copy of the GNU Lesser General Public
  26.    License along with this library; if not, write to the Free Software
  27.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28.    MA  02111-1307  USA
  29.  
  30.  
  31.    Sun Industry Standards Source License Version 1.1
  32.    =================================================
  33.    The contents of this file are subject to the Sun Industry Standards
  34.    Source License Version 1.1 (the "License"); You may not use this file
  35.    except in compliance with the License. You may obtain a copy of the
  36.    License at http://www.openoffice.org/license.html.
  37.  
  38.    Software provided under this License is provided on an "AS IS" basis,
  39.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  40.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  41.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  42.    See the License for the specific provisions governing your rights and
  43.    obligations concerning the Software.
  44.  
  45.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  46.  
  47.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  48.  
  49.    All Rights Reserved.
  50.  
  51.    Contributor(s): _______________________________________
  52.    
  53.  -->
  54. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  55.     <xsl:template match="style:paragraph-properties" mode="paragraph">
  56.         <w:pPr>
  57.             <w:adjustRightInd w:val="off"/>
  58.             <xsl:if test="@fo:break-before = 'page'">
  59.                 <w:pageBreakBefore w:val="on"/>
  60.             </xsl:if>
  61.             <xsl:if test="contains(@style:writing-mode, 'rl')">
  62.                 <w:bidi/>
  63.             </xsl:if>
  64.             <xsl:choose>
  65.                 <xsl:when test="@fo:text-align-last = 'start'">
  66.                     <xsl:choose>
  67.                         <xsl:when test="contains(@style:writing-mode, 'rl')">
  68.                             <w:jc w:val="right"/>
  69.                         </xsl:when>
  70.                         <xsl:otherwise>
  71.                             <w:jc w:val="left"/>
  72.                         </xsl:otherwise>
  73.                     </xsl:choose>
  74.                 </xsl:when>
  75.                 <xsl:when test="@fo:text-align-last = 'justify'">
  76.                     <w:jc w:val="distribute"/>
  77.                 </xsl:when>
  78.                 <xsl:when test="@fo:text-align-last = 'center'">
  79.                     <w:jc w:val="center"/>
  80.                 </xsl:when>
  81.                 <xsl:when test="@fo:text-align = 'start'">
  82.                     <xsl:choose>
  83.                         <xsl:when test="contains(@style:writing-mode, 'rl')">
  84.                             <w:jc w:val="right"/>
  85.                         </xsl:when>
  86.                         <xsl:otherwise>
  87.                             <w:jc w:val="left"/>
  88.                         </xsl:otherwise>
  89.                     </xsl:choose>
  90.                 </xsl:when>
  91.                 <xsl:when test="@fo:text-align = 'end'">
  92.                     <xsl:choose>
  93.                         <xsl:when test="contains(@style:writing-mode, 'rl')">
  94.                             <w:jc w:val="left"/>
  95.                         </xsl:when>
  96.                         <xsl:otherwise>
  97.                             <w:jc w:val="right"/>
  98.                         </xsl:otherwise>
  99.                     </xsl:choose>
  100.                 </xsl:when>
  101.                 <xsl:when test="@fo:text-align = 'justify'">
  102.                     <w:jc w:val="distribute"/>
  103.                 </xsl:when>
  104.                 <xsl:when test="@fo:text-align = 'center'">
  105.                     <w:jc w:val="center"/>
  106.                 </xsl:when>
  107.             </xsl:choose>
  108.             <w:spacing>
  109.                 <xsl:choose>
  110.                     <xsl:when test="@fo:line-height">
  111.                         <xsl:choose>
  112.                             <xsl:when test="contains(@fo:line-height, '%')">
  113.                                 <xsl:attribute name="w:line-rule">auto</xsl:attribute>
  114.                                 <xsl:attribute name="w:line"><xsl:value-of select="round(substring-before(@fo:line-height, '%') div 100 * 240)"/></xsl:attribute>
  115.                             </xsl:when>
  116.                             <xsl:otherwise>
  117.                                 <xsl:attribute name="w:line-rule">exact</xsl:attribute>
  118.                                 <xsl:attribute name="w:line"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:line-height"/></xsl:call-template></xsl:attribute>
  119.                             </xsl:otherwise>
  120.                         </xsl:choose>
  121.                     </xsl:when>
  122.                     <xsl:when test="@style:line-height-at-least">
  123.                         <xsl:attribute name="w:line-rule">at-least</xsl:attribute>
  124.                         <xsl:attribute name="w:line"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@style:line-height-at-least"/></xsl:call-template></xsl:attribute>
  125.                     </xsl:when>
  126.                     <xsl:when test="@style:line-spacing">
  127.                         <xsl:attribute name="w:line-rule">auto</xsl:attribute>
  128.                         <xsl:variable name="spacing">
  129.                             <xsl:call-template name="convert2twip">
  130.                                 <xsl:with-param name="value" select="@style:line-spacing"/>
  131.                             </xsl:call-template>
  132.                         </xsl:variable>
  133.                         <xsl:attribute name="w:line"><xsl:value-of select="round($spacing div 0.567)"/></xsl:attribute>
  134.                     </xsl:when>
  135.                 </xsl:choose>
  136.                 <xsl:if test="@fo:margin-top">
  137.                     <xsl:choose>
  138.                         <xsl:when test="contains(@fo:margin-top, '%')">
  139.                             <xsl:if test="../@style:parent-style-name">
  140.                                 <xsl:variable name="parent-size">
  141.                                     <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:margin-top"/>
  142.                                 </xsl:variable>
  143.                                 <xsl:variable name="w-number">
  144.                                     <xsl:call-template name="convert2twip">
  145.                                         <xsl:with-param name="value" select="$parent-size"/>
  146.                                     </xsl:call-template>
  147.                                 </xsl:variable>
  148.                                 <xsl:attribute name="w:before"><xsl:value-of select="round($w-number div 100 * substring-before(@fo:margin-top, '%'))"/></xsl:attribute>
  149.                             </xsl:if>
  150.                         </xsl:when>
  151.                         <xsl:otherwise>
  152.                             <xsl:attribute name="w:before"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:margin-top"/></xsl:call-template></xsl:attribute>
  153.                         </xsl:otherwise>
  154.                     </xsl:choose>
  155.                 </xsl:if>
  156.                 <xsl:if test="@fo:margin-bottom">
  157.                     <xsl:choose>
  158.                         <xsl:when test="contains(@fo:margin-bottom, '%')">
  159.                             <xsl:if test="../@style:parent-style-name">
  160.                                 <xsl:variable name="parent-size">
  161.                                     <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:margin-bottom"/>
  162.                                 </xsl:variable>
  163.                                 <xsl:variable name="w-number">
  164.                                     <xsl:call-template name="convert2twip">
  165.                                         <xsl:with-param name="value" select="$parent-size"/>
  166.                                     </xsl:call-template>
  167.                                 </xsl:variable>
  168.                                 <xsl:attribute name="w:after"><xsl:value-of select="round($w-number div 100 * substring-before(@fo:margin-bottom, '%'))"/></xsl:attribute>
  169.                             </xsl:if>
  170.                         </xsl:when>
  171.                         <xsl:otherwise>
  172.                             <xsl:attribute name="w:after"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:margin-bottom"/></xsl:call-template></xsl:attribute>
  173.                         </xsl:otherwise>
  174.                     </xsl:choose>
  175.                 </xsl:if>
  176.             </w:spacing>
  177.             <w:ind>
  178.                 <xsl:if test="@fo:margin-left">
  179.                     <xsl:choose>
  180.                         <xsl:when test="contains(@fo:margin-left, '%')">
  181.                             <xsl:if test="../@style:parent-style-name">
  182.                                 <xsl:variable name="parent-size">
  183.                                     <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:margin-left"/>
  184.                                 </xsl:variable>
  185.                                 <xsl:variable name="w-number">
  186.                                     <xsl:call-template name="convert2twip">
  187.                                         <xsl:with-param name="value" select="$parent-size"/>
  188.                                     </xsl:call-template>
  189.                                 </xsl:variable>
  190.                                 <xsl:attribute name="w:left"><xsl:value-of select="round($w-number div 100 * substring-before(@fo:margin-left, '%'))"/></xsl:attribute>
  191.                             </xsl:if>
  192.                         </xsl:when>
  193.                         <xsl:otherwise>
  194.                             <xsl:attribute name="w:left"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:margin-left"/></xsl:call-template></xsl:attribute>
  195.                         </xsl:otherwise>
  196.                     </xsl:choose>
  197.                 </xsl:if>
  198.                 <xsl:if test="@fo:margin-right">
  199.                     <xsl:choose>
  200.                         <xsl:when test="contains(@fo:margin-right, '%')">
  201.                             <xsl:if test="../@style:parent-style-name">
  202.                                 <xsl:variable name="parent-size">
  203.                                     <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:margin-right"/>
  204.                                 </xsl:variable>
  205.                                 <xsl:variable name="w-number">
  206.                                     <xsl:call-template name="convert2twip">
  207.                                         <xsl:with-param name="value" select="$parent-size"/>
  208.                                     </xsl:call-template>
  209.                                 </xsl:variable>
  210.                                 <xsl:attribute name="w:right"><xsl:value-of select="round($w-number div 100 * substring-before(@fo:margin-right, '%'))"/></xsl:attribute>
  211.                             </xsl:if>
  212.                         </xsl:when>
  213.                         <xsl:otherwise>
  214.                             <xsl:attribute name="w:right"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:margin-right"/></xsl:call-template></xsl:attribute>
  215.                         </xsl:otherwise>
  216.                     </xsl:choose>
  217.                 </xsl:if>
  218.                 <xsl:if test="@fo:text-indent">
  219.                     <xsl:choose>
  220.                         <!-- When @style:auto-text-indent='true' @fo:text-indent ignored, use 283 for all font size -->
  221.                         <xsl:when test="@style:auto-text-indent='true'">
  222.                             <xsl:attribute name="w:first-line">283</xsl:attribute>
  223.                         </xsl:when>
  224.                         <xsl:when test="contains(@fo:text-indent, '%')">
  225.                             <xsl:if test="../@style:parent-style-name">
  226.                                 <xsl:variable name="parent-size">
  227.                                     <xsl:value-of select="key('paragraph-style', ../@style:parent-style-name)/style:paragraph-properties/@fo:text-indent"/>
  228.                                 </xsl:variable>
  229.                                 <xsl:variable name="w-number">
  230.                                     <xsl:call-template name="convert2twip">
  231.                                         <xsl:with-param name="value" select="$parent-size"/>
  232.                                     </xsl:call-template>
  233.                                 </xsl:variable>
  234.                                 <xsl:choose>
  235.                                     <xsl:when test="$w-number < 0">
  236.                                         <xsl:attribute name="w:hanging"><xsl:value-of select="round($w-number div -100 * substring-before(@fo:text-indent, '%'))"/></xsl:attribute>
  237.                                     </xsl:when>
  238.                                     <xsl:otherwise>
  239.                                         <xsl:attribute name="w:first-line"><xsl:value-of select="round($w-number div 100 * substring-before(@fo:text-indent, '%'))"/></xsl:attribute>
  240.                                     </xsl:otherwise>
  241.                                 </xsl:choose>
  242.                             </xsl:if>
  243.                         </xsl:when>
  244.                         <xsl:when test="starts-with(@fo:text-indent,'-')">
  245.                             <xsl:attribute name="w:hanging"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="substring-after(@fo:text-indent,'-')"/></xsl:call-template></xsl:attribute>
  246.                         </xsl:when>
  247.                         <xsl:otherwise>
  248.                             <xsl:attribute name="w:first-line"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:text-indent"/></xsl:call-template></xsl:attribute>
  249.                         </xsl:otherwise>
  250.                     </xsl:choose>
  251.                 </xsl:if>
  252.             </w:ind>
  253.             <xsl:if test="contains(@fo:background-color, '#')">
  254.                 <w:shd w:val="clear" w:color="auto" w:fill="{substring-after(@fo:background-color, '#')}"/>
  255.             </xsl:if>
  256.             <xsl:if test="@fo:keep-with-next='true'">
  257.                 <w:keepNext/>
  258.             </xsl:if>
  259.             <xsl:choose>
  260.                 <xsl:when test="@fo:widows | @fo:orphans">
  261.                     <w:widowControl w:val="on"/>
  262.                 </xsl:when>
  263.                 <xsl:otherwise>
  264.                     <w:widowControl w:val="off"/>
  265.                 </xsl:otherwise>
  266.             </xsl:choose>
  267.             <xsl:if test="@style:break-inside = 'avoid'">
  268.                 <w:keepLines/>
  269.             </xsl:if>
  270.             <xsl:if test="@fo:hyphenate = 'false'">
  271.                 <w:suppressAutoHyphens/>
  272.             </xsl:if>
  273.             <xsl:if test="@style:snap-to-layout-grid='false'">
  274.                 <w:snapToGrid w:val="off"/>
  275.             </xsl:if>
  276.             <xsl:if test="style:tab-stops">
  277.                 <w:tabs>
  278.                     <xsl:for-each select="style:tab-stops/style:tab-stop">
  279.                         <w:tab>
  280.                             <xsl:choose>
  281.                                 <xsl:when test="@style:type='char'">
  282.                                     <xsl:attribute name="w:val">decimal</xsl:attribute>
  283.                                 </xsl:when>
  284.                                 <xsl:when test="@style:type">
  285.                                     <xsl:attribute name="w:val"><xsl:value-of select="@style:type"/></xsl:attribute>
  286.                                 </xsl:when>
  287.                                 <xsl:otherwise>
  288.                                     <xsl:attribute name="w:val">left</xsl:attribute>
  289.                                 </xsl:otherwise>
  290.                             </xsl:choose>
  291.                             <xsl:if test="@style:leader-char">
  292.                                 <xsl:choose>
  293.                                     <xsl:when test="@style:leader-char='-'">
  294.                                         <xsl:attribute name="w:leader">hyphen</xsl:attribute>
  295.                                     </xsl:when>
  296.                                     <xsl:when test="@style:leader-char='_'">
  297.                                         <xsl:attribute name="w:leader">underscore</xsl:attribute>
  298.                                     </xsl:when>
  299.                                     <xsl:when test="@style:leader-char='.'">
  300.                                         <xsl:attribute name="w:leader">dot</xsl:attribute>
  301.                                     </xsl:when>
  302.                                     <xsl:otherwise>
  303.                                         <xsl:attribute name="w:leader">dot</xsl:attribute>
  304.                                     </xsl:otherwise>
  305.                                 </xsl:choose>
  306.                             </xsl:if>
  307.                             <xsl:if test="@style:position">
  308.                                 <xsl:attribute name="w:pos"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@style:position"/></xsl:call-template></xsl:attribute>
  309.                             </xsl:if>
  310.                         </w:tab>
  311.                     </xsl:for-each>
  312.                 </w:tabs>
  313.             </xsl:if>
  314.             <xsl:if test="@style:line-break='normal'">
  315.                 <w:kinsoku w:val="off"/>
  316.             </xsl:if>
  317.             <xsl:if test="@style:punctuation-wrap='simple'">
  318.                 <w:overflowPunct w:val="off"/>
  319.             </xsl:if>
  320.             <xsl:if test="@style:text-autospace='none'">
  321.                 <w:autoSpaceDE w:val="off"/>
  322.                 <w:autoSpaceDN w:val="off"/>
  323.             </xsl:if>
  324.             <xsl:if test="@style:vertical-align">
  325.                 <xsl:element name="w:textAlignment">
  326.                     <xsl:choose>
  327.                         <xsl:when test="@style:vertical-align='middle'">
  328.                             <xsl:attribute name="w:val">center</xsl:attribute>
  329.                         </xsl:when>
  330.                         <xsl:otherwise>
  331.                             <xsl:attribute name="w:val"><xsl:value-of select="@style:vertical-align"/></xsl:attribute>
  332.                         </xsl:otherwise>
  333.                     </xsl:choose>
  334.                 </xsl:element>
  335.             </xsl:if>
  336.             <xsl:if test="@text:number-lines='false'">
  337.                 <w:supressLineNumbers/>
  338.             </xsl:if>
  339.             <xsl:variable name="border-top" select="@fo:border-top | @fo:border"/>
  340.             <xsl:variable name="border-bottom" select="@fo:border-bottom | @fo:border"/>
  341.             <xsl:variable name="border-left" select="@fo:border-left | @fo:border"/>
  342.             <xsl:variable name="border-right" select="@fo:border-right | @fo:border"/>
  343.             <xsl:variable name="border-line-width-top" select="@style:border-line-width-top | @style:border-line-width "/>
  344.             <xsl:variable name="border-line-width-bottom" select="@style:border-line-width-bottom | @style:border-line-width"/>
  345.             <xsl:variable name="border-line-width-left" select="@style:border-line-width-left | @style:border-line-width"/>
  346.             <xsl:variable name="border-line-width-right" select="@style:border-line-width-right | @style:border-line-width"/>
  347.             <xsl:variable name="padding-top" select="@fo:padding-top | @fo:padding"/>
  348.             <xsl:variable name="padding-bottom" select="@fo:padding-bottom | @fo:padding"/>
  349.             <xsl:variable name="padding-left" select="@fo:padding-left | @fo:padding"/>
  350.             <xsl:variable name="padding-right" select="@fo:padding-right | @fo:padding"/>
  351.             <w:pBdr>
  352.                 <xsl:if test="$border-top">
  353.                     <xsl:element name="w:top">
  354.                         <xsl:call-template name="get-border">
  355.                             <xsl:with-param name="so-border" select="$border-top"/>
  356.                             <xsl:with-param name="so-border-line-width" select="$border-line-width-top"/>
  357.                             <xsl:with-param name="so-border-position" select=" 'top' "/>
  358.                         </xsl:call-template>
  359.                         <xsl:attribute name="w:space"><xsl:call-template name="convert2pt"><xsl:with-param name="value" select="$padding-top"/></xsl:call-template></xsl:attribute>
  360.                         <xsl:if test="@style:shadow!='none'">
  361.                             <xsl:attribute name="w:shadow">on</xsl:attribute>
  362.                         </xsl:if>
  363.                     </xsl:element>
  364.                 </xsl:if>
  365.                 <xsl:if test="$border-bottom">
  366.                     <xsl:element name="w:bottom">
  367.                         <xsl:call-template name="get-border">
  368.                             <xsl:with-param name="so-border" select="$border-bottom"/>
  369.                             <xsl:with-param name="so-border-line-width" select="$border-line-width-bottom"/>
  370.                             <xsl:with-param name="so-border-position" select=" 'bottom' "/>
  371.                         </xsl:call-template>
  372.                         <xsl:attribute name="w:space"><xsl:call-template name="convert2pt"><xsl:with-param name="value" select="$padding-bottom"/></xsl:call-template></xsl:attribute>
  373.                         <xsl:if test="@style:shadow!='none'">
  374.                             <xsl:attribute name="w:shadow">on</xsl:attribute>
  375.                         </xsl:if>
  376.                     </xsl:element>
  377.                 </xsl:if>
  378.                 <xsl:if test="$border-left">
  379.                     <xsl:element name="w:left">
  380.                         <xsl:call-template name="get-border">
  381.                             <xsl:with-param name="so-border" select="$border-left"/>
  382.                             <xsl:with-param name="so-border-line-width" select="$border-line-width-left"/>
  383.                             <xsl:with-param name="so-border-position" select=" 'left' "/>
  384.                         </xsl:call-template>
  385.                         <xsl:attribute name="w:space"><xsl:call-template name="convert2pt"><xsl:with-param name="value" select="$padding-left"/></xsl:call-template></xsl:attribute>
  386.                         <xsl:if test="@style:shadow!='none'">
  387.                             <xsl:attribute name="w:shadow">on</xsl:attribute>
  388.                         </xsl:if>
  389.                     </xsl:element>
  390.                 </xsl:if>
  391.                 <xsl:if test="$border-right">
  392.                     <xsl:element name="w:right">
  393.                         <xsl:call-template name="get-border">
  394.                             <xsl:with-param name="so-border" select="$border-right"/>
  395.                             <xsl:with-param name="so-border-line-width" select="$border-line-width-right"/>
  396.                             <xsl:with-param name="so-border-position" select=" 'right' "/>
  397.                         </xsl:call-template>
  398.                         <xsl:attribute name="w:space"><xsl:call-template name="convert2pt"><xsl:with-param name="value" select="$padding-right"/></xsl:call-template></xsl:attribute>
  399.                         <xsl:if test="@style:shadow!='none'">
  400.                             <xsl:attribute name="w:shadow">on</xsl:attribute>
  401.                         </xsl:if>
  402.                     </xsl:element>
  403.                 </xsl:if>
  404.                 <xsl:if test="@style:shadow!='none' and not(@fo:border-top | @fo:border-bottom | @fo:border-left | @fo:border-right | @fo:border)">
  405.                     <xsl:element name="w:right">
  406.                         <xsl:attribute name="w:shadow">on</xsl:attribute>
  407.                         <xsl:attribute name="w:val">single</xsl:attribute>
  408.                         <xsl:variable name="shadow-size">
  409.                             <xsl:call-template name="convert2cm">
  410.                                 <xsl:with-param name="value" select="substring-after(substring-after(@style:shadow, ' '), ' ')"/>
  411.                             </xsl:call-template>
  412.                         </xsl:variable>
  413.                         <xsl:attribute name="w:sz"><xsl:choose><xsl:when test="$shadow-size <= 0.08">12</xsl:when><xsl:when test="$shadow-size <= 0.14">18</xsl:when><xsl:when test="$shadow-size <= 0.20">24</xsl:when><xsl:when test="$shadow-size <= 0.25">36</xsl:when><xsl:otherwise>48</xsl:otherwise></xsl:choose></xsl:attribute>
  414.                     </xsl:element>
  415.                     <xsl:element name="w:bottom">
  416.                         <xsl:attribute name="w:shadow">on</xsl:attribute>
  417.                         <xsl:attribute name="w:val">single</xsl:attribute>
  418.                         <xsl:variable name="shadow-size">
  419.                             <xsl:call-template name="convert2cm">
  420.                                 <xsl:with-param name="value" select="substring-after(substring-after(@style:shadow, ' '), ' ')"/>
  421.                             </xsl:call-template>
  422.                         </xsl:variable>
  423.                         <xsl:attribute name="w:sz"><xsl:choose><xsl:when test="$shadow-size <= 0.08">12</xsl:when><xsl:when test="$shadow-size <= 0.14">18</xsl:when><xsl:when test="$shadow-size <= 0.20">24</xsl:when><xsl:when test="$shadow-size <= 0.25">36</xsl:when><xsl:otherwise>48</xsl:otherwise></xsl:choose></xsl:attribute>
  424.                     </xsl:element>
  425.                 </xsl:if>
  426.             </w:pBdr>
  427.             <w:ind>
  428.                 <xsl:if test="$padding-left!=''">
  429.                     <xsl:attribute name="w:left"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$padding-left"/></xsl:call-template></xsl:attribute>
  430.                 </xsl:if>
  431.                 <xsl:if test="$padding-right!='' ">
  432.                     <xsl:attribute name="w:right"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="$padding-right"/></xsl:call-template></xsl:attribute>
  433.                 </xsl:if>
  434.             </w:ind>
  435.             <xsl:variable name="stylename">
  436.                 <xsl:value-of select="../@style:name"/>
  437.             </xsl:variable>
  438.             <xsl:if test="/office:document/office:body//text:h[@text:style-name = $stylename]">
  439.                 <xsl:variable name="headinglevel">
  440.                     <xsl:value-of select="/office:document/office:body//text:h[@text:style-name = $stylename]/@text:level"/>
  441.                 </xsl:variable>
  442.                 <xsl:if test="/office:document/office:styles/text:outline-style/text:outline-level-style[@text:level = $headinglevel]">
  443.                     <w:listPr>
  444.                         <w:ilvl w:val="{$headinglevel -1}"/>
  445.                         <w:ilfo w:val="1"/>
  446.                     </w:listPr>
  447.                 </xsl:if>
  448.             </xsl:if>
  449.         </w:pPr>
  450.     </xsl:template>
  451.     <xsl:template match="style:text-properties" mode="character">
  452.         <w:rPr>
  453.             <xsl:if test="@svg:font-family | @style:font-name | @style:font-name-asian | @style:font-name-complex">
  454.                 <w:rFonts>
  455.                     <xsl:variable name="fontname">
  456.                         <xsl:choose>
  457.                             <xsl:when test='starts-with(@svg:font-family,"'")'>
  458.                                 <xsl:value-of select='substring-before(substring-after(@svg:font-family,"'"),"'")'/>
  459.                             </xsl:when>
  460.                             <xsl:when test="@svg:font-family">
  461.                                 <xsl:value-of select="@svg:font-family"/>
  462.                             </xsl:when>
  463.                             <xsl:when test="@style:font-name">
  464.                                 <xsl:value-of select="@style:font-name"/>
  465.                             </xsl:when>
  466.                         </xsl:choose>
  467.                     </xsl:variable>
  468.                     <xsl:if test="string-length($fontname)!=0">
  469.                         <xsl:attribute name="w:ascii"><xsl:value-of select="$fontname"/></xsl:attribute>
  470.                         <xsl:attribute name="w:h-ansi"><xsl:value-of select="$fontname"/></xsl:attribute>
  471.                     </xsl:if>
  472.                     <xsl:if test="@style:font-name-asian">
  473.                         <xsl:attribute name="w:fareast"><xsl:value-of select="@style:font-name-asian"/></xsl:attribute>
  474.                     </xsl:if>
  475.                     <xsl:if test="@style:font-name-complex">
  476.                         <xsl:attribute name="w:cs"><xsl:value-of select="@style:font-name-complex"/></xsl:attribute>
  477.                     </xsl:if>
  478.                 </w:rFonts>
  479.             </xsl:if>
  480.             <!-- relative font sizes not supported yet. -->
  481.             <xsl:if test="contains(@fo:font-size, 'pt')">
  482.                 <w:sz w:val="{substring-before(@fo:font-size,'pt') * 2}"/>
  483.             </xsl:if>
  484.             <xsl:if test="contains(@fo:font-size-complex, 'pt')">
  485.                 <w:sz-cs w:val="{substring-before(@fo:font-size-complex, 'pt') * 2}"/>
  486.             </xsl:if>
  487.             <xsl:if test="@fo:font-style = 'italic' or @fo:font-style-asian = 'italic'">
  488.                 <w:i/>
  489.             </xsl:if>
  490.             <xsl:if test="@fo:font-style-complex = 'italic'">
  491.                 <w:i-cs/>
  492.             </xsl:if>
  493.             <xsl:if test="@fo:font-weight = 'bold' or @fo:font-weight-asian = 'bold'">
  494.                 <w:b/>
  495.             </xsl:if>
  496.             <xsl:if test="@fo:font-weight-complex = 'bold'">
  497.                 <w:b-cs/>
  498.             </xsl:if>
  499.             <xsl:if test="@style:text-underline-style">
  500.                 <w:u>
  501.                     <xsl:variable name="w-u">
  502.                         <xsl:choose>
  503.                             <xsl:when test="@style:text-underline-style = 'solid'">
  504.                                 <xsl:choose>
  505.                                     <xsl:when test="@style:text-underline-type = 'double'">double</xsl:when>
  506.                                     <xsl:when test="@style:text-underline-width = 'bold'">thick</xsl:when>
  507.                                     <xsl:otherwise>single</xsl:otherwise>
  508.                                 </xsl:choose>
  509.                             </xsl:when>
  510.                             <xsl:when test="@style:text-underline-style = 'dotted'">
  511.                                 <xsl:choose>
  512.                                     <xsl:when test="@style:text-underline-type = 'double'">dotted-double</xsl:when>
  513.                                     <xsl:when test="@style:text-underline-width = 'bold'">dotted-heavy</xsl:when>
  514.                                     <xsl:otherwise>dotted</xsl:otherwise>
  515.                                 </xsl:choose>
  516.                             </xsl:when>
  517.                             <xsl:when test="@style:text-underline-style = 'dash'">
  518.                                 <xsl:choose>
  519.                                     <xsl:when test="@style:text-underline-type = 'double'">dashed-double</xsl:when>
  520.                                     <xsl:when test="@style:text-underline-width = 'bold'">dashed-heavy</xsl:when>
  521.                                     <xsl:otherwise>dash</xsl:otherwise>
  522.                                 </xsl:choose>
  523.                             </xsl:when>
  524.                             <xsl:when test="@style:text-underline-style = 'long-dash'">
  525.                                 <xsl:choose>
  526.                                     <xsl:when test="@style:text-underline-type = 'double'">dash-long-double</xsl:when>
  527.                                     <xsl:when test="@style:text-underline-width = 'bold'">dash-long-heavy</xsl:when>
  528.                                     <xsl:otherwise>dash-long</xsl:otherwise>
  529.                                 </xsl:choose>
  530.                             </xsl:when>
  531.                             <xsl:when test="@style:text-underline-style = 'dot-dash'">
  532.                                 <xsl:choose>
  533.                                     <xsl:when test="@style:text-underline-type = 'double'">dot-dash-double</xsl:when>
  534.                                     <xsl:when test="@style:text-underline-width = 'bold'">dash-dot-heavy</xsl:when>
  535.                                     <xsl:otherwise>dot-dash</xsl:otherwise>
  536.                                 </xsl:choose>
  537.                             </xsl:when>
  538.                             <xsl:when test="@style:text-underline-style = 'dot-dot-dash'">
  539.                                 <xsl:choose>
  540.                                     <xsl:when test="@style:text-underline-type = 'double'">dot-dot-dash-double</xsl:when>
  541.                                     <xsl:when test="@style:text-underline-width = 'bold'">dash-dot-dot-heavy</xsl:when>
  542.                                     <xsl:otherwise>dot-dot-dash</xsl:otherwise>
  543.                                 </xsl:choose>
  544.                             </xsl:when>
  545.                             <xsl:when test="@style:text-underline-style = 'wave'">
  546.                                 <xsl:choose>
  547.                                     <xsl:when test="@style:text-underline-type = 'double'">wavy-double</xsl:when>
  548.                                     <xsl:when test="@style:text-underline-width = 'bold'">wavy-heavy</xsl:when>
  549.                                     <xsl:otherwise>wave</xsl:otherwise>
  550.                                 </xsl:choose>
  551.                             </xsl:when>
  552.                             <xsl:otherwise>
  553.                                 <xsl:value-of select="@style:text-underline-style"/>
  554.                             </xsl:otherwise>
  555.                         </xsl:choose>
  556.                     </xsl:variable>
  557.                     <xsl:attribute name="w:val"><xsl:value-of select="$w-u"/></xsl:attribute>
  558.                     <xsl:if test="contains(@style:text-underline-color,'#')">
  559.                         <xsl:attribute name="w:color"><xsl:value-of select="substring-after(@style:text-underline-color,'#')"/></xsl:attribute>
  560.                     </xsl:if>
  561.                 </w:u>
  562.             </xsl:if>
  563.             <xsl:if test="@style:text-shadow | @fo:text-shadow">
  564.                 <w:shadow/>
  565.             </xsl:if>
  566.             <xsl:if test="string-length(@style:text-line-through-style) > 0">
  567.                 <xsl:choose>
  568.                     <xsl:when test="@style:text-line-through-type = 'double'">
  569.                         <w:dstrike/>
  570.                     </xsl:when>
  571.                     <xsl:when test="@style:text-line-through-style = 'solid'">
  572.                         <w:strike/>
  573.                     </xsl:when>
  574.                     <xsl:otherwise>
  575.                         <w:strike/>
  576.                     </xsl:otherwise>
  577.                 </xsl:choose>
  578.             </xsl:if>
  579.             <xsl:if test="@fo:color">
  580.                 <w:color>
  581.                     <xsl:choose>
  582.                         <xsl:when test="@fo:color != '#000000'">
  583.                             <xsl:attribute name="w:val"><xsl:value-of select="substring-after(@fo:color,'#')"/></xsl:attribute>
  584.                         </xsl:when>
  585.                         <xsl:otherwise>
  586.                             <xsl:attribute name="w:val">auto</xsl:attribute>
  587.                         </xsl:otherwise>
  588.                     </xsl:choose>
  589.                 </w:color>
  590.             </xsl:if>
  591.             <xsl:if test="@fo:font-variant = 'small-caps'">
  592.                 <w:smallCaps/>
  593.             </xsl:if>
  594.             <xsl:if test="@fo:text-transform = 'uppercase'">
  595.                 <w:caps/>
  596.             </xsl:if>
  597.             <xsl:if test="@style:font-relief = 'engraved'">
  598.                 <w:imprint/>
  599.             </xsl:if>
  600.             <xsl:if test="@style:font-relief = 'embossed'">
  601.                 <w:emboss/>
  602.             </xsl:if>
  603.             <xsl:if test="@style:text-outline = 'true'">
  604.                 <w:outline/>
  605.             </xsl:if>
  606.             <xsl:if test="contains(@style:text-scale,'%')">
  607.                 <w:w w:val="{substring-before(@style:text-scale,'%')}"/>
  608.             </xsl:if>
  609.             <xsl:if test="@style:text-emphasize">
  610.                 <w:em>
  611.                     <xsl:choose>
  612.                         <xsl:when test="contains(@style:text-emphasize, 'accent')">
  613.                             <xsl:attribute name="w:val">comma</xsl:attribute>
  614.                         </xsl:when>
  615.                         <xsl:when test="contains(@style:text-emphasize, 'disc')">
  616.                             <xsl:attribute name="w:val">under-dot</xsl:attribute>
  617.                         </xsl:when>
  618.                         <xsl:when test="contains(@style:text-emphasize, 'none')">
  619.                             <xsl:attribute name="w:val">none</xsl:attribute>
  620.                         </xsl:when>
  621.                         <xsl:when test="contains(@style:text-emphasize, 'dot below')">
  622.                             <xsl:attribute name="w:val">under-dot</xsl:attribute>
  623.                         </xsl:when>
  624.                         <xsl:when test="contains(@style:text-emphasize, 'dot above')">
  625.                             <xsl:attribute name="w:val">dot</xsl:attribute>
  626.                         </xsl:when>
  627.                         <xsl:when test="contains(@style:text-emphasize, 'circle')">
  628.                             <xsl:attribute name="w:val">dot</xsl:attribute>
  629.                         </xsl:when>
  630.                     </xsl:choose>
  631.                 </w:em>
  632.             </xsl:if>
  633.             <xsl:if test="@fo:letter-spacing != 'normal'">
  634.                 <w:spacing>
  635.                     <xsl:attribute name="w:val"><xsl:call-template name="convert2twip"><xsl:with-param name="value" select="@fo:letter-spacing"/></xsl:call-template></xsl:attribute>
  636.                 </w:spacing>
  637.             </xsl:if>
  638.             <xsl:if test="@style:text-blinking = 'true'">
  639.                 <w:effect w:val="blink-background"/>
  640.             </xsl:if>
  641.             <xsl:if test="@fo:language | @fo:language-asian | @fo:language-complex">
  642.                 <w:lang>
  643.                     <xsl:if test="@fo:language and @fo:country">
  644.                         <xsl:attribute name="w:val"><xsl:value-of select="concat(@fo:language, '-', @fo:country)"/></xsl:attribute>
  645.                     </xsl:if>
  646.                     <xsl:if test="@fo:language-asian and @fo:country-asian">
  647.                         <xsl:attribute name="w:fareast"><xsl:value-of select="concat(@fo:language-asian, '-', @fo:country-asian)"/></xsl:attribute>
  648.                     </xsl:if>
  649.                     <xsl:if test="@fo:language-complex and @fo:language-complex">
  650.                         <xsl:attribute name="w:bidi"><xsl:value-of select="concat(@fo:language-complex, '-', @fo:language-complex)"/></xsl:attribute>
  651.                     </xsl:if>
  652.                 </w:lang>
  653.             </xsl:if>
  654.             <xsl:if test="@style:text-position">
  655.                 <xsl:variable name="position">
  656.                     <xsl:choose>
  657.                         <xsl:when test="starts-with(@style:text-position, 'super')">superscript_0</xsl:when>
  658.                         <xsl:when test="starts-with(@style:text-position, 'sub')">subscript_0</xsl:when>
  659.                         <xsl:when test="starts-with(@style:text-position, '-')">
  660.                             <xsl:value-of select="concat('subscript_', substring-before(@style:text-position,'%'))"/>
  661.                         </xsl:when>
  662.                         <xsl:otherwise>
  663.                             <xsl:value-of select="concat('superscript_', substring-before(@style:text-position,'%'))"/>
  664.                         </xsl:otherwise>
  665.                     </xsl:choose>
  666.                 </xsl:variable>
  667.                 <w:vertAlign>
  668.                     <xsl:attribute name="w:val"><xsl:value-of select="substring-before($position,'_')"/></xsl:attribute>
  669.                 </w:vertAlign>
  670.                 <!-- Raised/Lowed position is difficult to map to MSWord w:position, Writer use %, but Word use half-point(not relative position). Since it's difficult to get font-size, use 12pt as default font-size -->
  671.                 <w:position>
  672.                     <xsl:attribute name="w:val"><xsl:choose><xsl:when test="substring-after($position, '_') = 0">0</xsl:when><xsl:otherwise><xsl:value-of select="round(substring-after($position, '_') div 6)"/></xsl:otherwise></xsl:choose></xsl:attribute>
  673.                 </w:position>
  674.             </xsl:if>
  675.             <xsl:if test="@text:display = 'true'">
  676.                 <w:vanish/>
  677.             </xsl:if>
  678.             <xsl:if test="contains(@fo:background-color, '#')">
  679.                 <w:shd w:val="clear" w:color="auto" w:fill="{substring-after(@fo:background-color, '#')}"/>
  680.             </xsl:if>
  681.         </w:rPr>
  682.     </xsl:template>
  683.     <xsl:template match="text:p | text:h">
  684.         <w:p>
  685.             <w:pPr>
  686.                 <xsl:if test="@text:style-name">
  687.                     <w:pStyle w:val="{@text:style-name}"/>
  688.                 </xsl:if>
  689.                 <xsl:if test="@text:level">
  690.                     <w:outlineLvl w:val="{@text:level - 1}"/>
  691.                 </xsl:if>
  692.                 <xsl:variable name="following-paragraph-heading-table" select="following::*[(name()= 'text:p' or name()= 'text:h' or name()= 'table:table')]"/>
  693.                 <xsl:variable name="following-section" select="following::text:section[1]"/>
  694.                 <xsl:variable name="ancestor-section" select="ancestor::text:section"/>
  695.                 <!-- if the following neighbour paragraph/heading are slave of one master style, or new section starts,
  696.                  then a new page will start -->
  697.                 <xsl:variable name="next-is-new-page" select="boolean(key( 'slave-style', $following-paragraph-heading-table[1]/@*[name()='text:style-name' or name()='table:style-name']))"/>
  698.                 <xsl:variable name="next-is-new-section">
  699.                     <xsl:if test="$following-section and generate-id($following-section/descendant::*[(name()= 'text:p' or name()= 'text:h' or name()= 'table:table') and position() =1]) = generate-id($following-paragraph-heading-table[1])">
  700.                         <xsl:value-of select="'yes'"/>
  701.                     </xsl:if>
  702.                 </xsl:variable>
  703.                 <xsl:variable name="next-is-section-end">
  704.                     <xsl:if test="$ancestor-section and generate-id($ancestor-section[1]/following::*[(name()= 'text:p' or name()= 'text:h' or name()= 'table:table') and position() =1]) = generate-id($following-paragraph-heading-table[1])">
  705.                         <xsl:value-of select="'yes'"/>
  706.                     </xsl:if>
  707.                 </xsl:variable>
  708.                 <xsl:if test="ancestor::office:body and not(ancestor::text:footnote or ancestor::text:endnote) and ($next-is-new-page or $next-is-new-section = 'yes' or $next-is-section-end = 'yes')">
  709.                     <w:sectPr>
  710.                         <xsl:apply-templates select="/office:document/office:styles/text:footnotes-configuration">
  711.                             <xsl:with-param name="within-section" select="'yes'"/>
  712.                         </xsl:apply-templates>
  713.                         <xsl:apply-templates select="/office:document/office:styles/text:endnotes-configuration">
  714.                             <xsl:with-param name="within-section" select="'yes'"/>
  715.                         </xsl:apply-templates>
  716.                         <xsl:choose>
  717.                             <xsl:when test="key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])">
  718.                                 <xsl:apply-templates select="key('master-page', key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])[1]/@style:master-page-name)"/>
  719.                                 <xsl:if test="$ancestor-section">
  720.                                     <xsl:apply-templates select="key('section-style',$ancestor-section[1]/@text:style-name)" mode="section">
  721.                                         <xsl:with-param name="master-page" select="key( 'page-layout', key('master-page', key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])[1]/@style:master-page-name)/@style:page-layout-name)"/>
  722.                                     </xsl:apply-templates>
  723.                                 </xsl:if>
  724.                                 <xsl:if test="key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number">
  725.                                     <!-- in M$ word the header and footer associate with the w:sectPr, but in StarOffice writer the header and footer associate with the style:master-page -->
  726.                                     <xsl:variable name="pagenumber_start">
  727.                                         <xsl:value-of select=" key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number"/>
  728.                                     </xsl:variable>
  729.                                     <xsl:if test=" number($pagenumber_start)  > 0 ">
  730.                                         <w:pgNumType w:start="{$pagenumber_start}"/>
  731.                                     </xsl:if>
  732.                                     <!-- comment out the below line to enable the header and footer display normally when style:page-number =0  -->
  733.                                     <!--w:pgNumType w:start="{key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])/style:paragraph-properties/@style:page-number}"/ -->
  734.                                 </xsl:if>
  735.                             </xsl:when>
  736.                             <xsl:otherwise>
  737.                                 <xsl:variable name="preceding-style" select="preceding::*[(name()= 'text:p' or name()= 'text:h' or name()= 'table:table') and key( 'slave-style', @*[name()='text:style-name' or name()='table:style-name'])]"/>
  738.                                 <xsl:choose>
  739.                                     <xsl:when test="$preceding-style">
  740.                                         <xsl:apply-templates select="key('master-page', key( 'slave-style', $preceding-style[1]/@*[name()='text:style-name' or name()='table:style-name'])[1]/@style:master-page-name)"/>
  741.                                     </xsl:when>
  742.                                     <xsl:otherwise>
  743.                                         <xsl:apply-templates select="/office:document/office:master-styles/style:master-page[1]"/>
  744.                                     </xsl:otherwise>
  745.                                 </xsl:choose>
  746.                                 <xsl:if test="$ancestor-section">
  747.                                     <xsl:choose>
  748.                                         <xsl:when test="$preceding-style">
  749.                                             <xsl:apply-templates select="key('section-style',$ancestor-section[1]/@text:style-name)" mode="section">
  750.                                                 <xsl:with-param name="master-page" select="key( 'page-layout', key('master-page', key( 'slave-style', $preceding-style[1]/@*[name()='text:style-name' or name()='table:style-name'])[1]/@style:master-page-name)/@style:page-layout-name)"/>
  751.                                             </xsl:apply-templates>
  752.                                         </xsl:when>
  753.                                         <xsl:otherwise>
  754.                                             <xsl:apply-templates select="key('section-style',$ancestor-section[1]/@text:style-name)" mode="section">
  755.                                                 <xsl:with-param name="master-page" select="/office:document/office:automatic-styles/style:page-layout[1]"/>
  756.                                             </xsl:apply-templates>
  757.                                         </xsl:otherwise>
  758.                                     </xsl:choose>
  759.                                 </xsl:if>
  760.                             </xsl:otherwise>
  761.                         </xsl:choose>
  762.                     </w:sectPr>
  763.                 </xsl:if>
  764.                 <!-- add for office:annotation style G.Y. -->
  765.                 <xsl:if test="name(..)= 'office:annotation' ">
  766.                     <w:pStyle w:val="CommentText"/>
  767.                 </xsl:if>
  768.                 <!-- add by wym for listPr -->
  769.                 <xsl:if test="ancestor::text:ordered-list | ancestor::text:unordered-list | ancestor::text:list">
  770.                     <xsl:variable name="listname">
  771.                         <xsl:value-of select="ancestor::text:ordered-list/@text:style-name | ancestor::text:unordered-list/@text:style-name  | ancestor::text:list/@text:style-name"/>
  772.                     </xsl:variable>
  773.                     <xsl:variable name="currlevel">
  774.                         <xsl:value-of select="count(ancestor::text:list-item|ancestor::text:list-header)"/>
  775.                     </xsl:variable>
  776.                     <xsl:choose>
  777.                         <xsl:when test="string-length($listname)!=0 and $currlevel < 10">
  778.                             <xsl:variable name="currlist">
  779.                                 <xsl:apply-templates select="key('list-style', $listname)" mode="count"/>
  780.                             </xsl:variable>
  781.                             <w:listPr>
  782.                                 <w:ilvl w:val="{number($currlevel)-1}"/>
  783.                                 <w:ilfo w:val="{$currlist}"/>
  784.                             </w:listPr>
  785.                         </xsl:when>
  786.                         <xsl:when test="string-length($listname)!=0">
  787.                             <xsl:for-each select="key('list-style', $listname)">
  788.                                 <xsl:variable name="spacebefore">
  789.                                     <xsl:choose>
  790.                                         <xsl:when test="*[@text:level=$currlevel]/style:list-level-properties/@text:space-before">
  791.                                             <xsl:call-template name="convert2twip">
  792.                                                 <xsl:with-param name="value" select="*[@text:level=$currlevel]/style:list-level-properties/@text:space-before"/>
  793.                                             </xsl:call-template>
  794.                                         </xsl:when>
  795.                                         <xsl:otherwise>0</xsl:otherwise>
  796.                                     </xsl:choose>
  797.                                 </xsl:variable>
  798.                                 <xsl:variable name="space2text">
  799.                                     <xsl:choose>
  800.                                         <xsl:when test="*[@text:level=$currlevel]/style:list-level-properties/@text:min-label-width">
  801.                                             <xsl:call-template name="convert2twip">
  802.                                                 <xsl:with-param name="value" select="*[@text:level=$currlevel]/style:list-level-properties/@text:min-label-width"/>
  803.                                             </xsl:call-template>
  804.                                         </xsl:when>
  805.                                         <xsl:otherwise>0</xsl:otherwise>
  806.                                     </xsl:choose>
  807.                                 </xsl:variable>
  808.                                 <w:ind w:left="{number($space2text)+number($spacebefore)}" w:hanging="{$space2text}"/>
  809.                             </xsl:for-each>
  810.                         </xsl:when>
  811.                         <xsl:otherwise>
  812.                             <w:listPr>
  813.                                 <w:ilvl w:val="{number($currlevel)-1}"/>
  814.                                 <w:ilfo w:val="1"/>
  815.                             </w:listPr>
  816.                         </xsl:otherwise>
  817.                     </xsl:choose>
  818.                 </xsl:if>
  819.                 <!-- end of listPr -->
  820.             </w:pPr>
  821.             <!-- get break column from style -->
  822.             <xsl:variable name="style" select="key('paragraph-style', @text:style-name)/style:paragraph-properties"/>
  823.             <xsl:if test="$style/@fo:break-before = 'column'">
  824.                 <w:r>
  825.                     <w:br w:type="column"/>
  826.                 </w:r>
  827.             </xsl:if>
  828.             <xsl:if test="parent::office:text and not(preceding-sibling::text:p)">
  829.                 <xsl:call-template name="PageLevelGraphic"/>
  830.             </xsl:if>
  831.             <xsl:if test="parent::text:footnote-body and not(preceding-sibling::*)">
  832.                 <w:r>
  833.                     <w:rPr>
  834.                         <w:rStyle w:val="{/office:document/office:styles/text:footnotes-configuration/@text:citation-style-name}"/>
  835.                     </w:rPr>
  836.                     <xsl:choose>
  837.                         <xsl:when test="../../text:footnote-citation/@text:label">
  838.                             <w:t>
  839.                                 <xsl:value-of select="../../text:footnote-citation/@text:label"/>
  840.                             </w:t>
  841.                         </xsl:when>
  842.                         <xsl:otherwise>
  843.                             <w:footnoteRef/>
  844.                         </xsl:otherwise>
  845.                     </xsl:choose>
  846.                 </w:r>
  847.                 <w:r>
  848.                     <w:tab/>
  849.                 </w:r>
  850.             </xsl:if>
  851.             <xsl:if test="parent::text:endnote-body and not(preceding-sibling::*)">
  852.                 <w:r>
  853.                     <w:rPr>
  854.                         <w:rStyle w:val="{/office:document/office:styles/text:endnotes-configuration/@text:citation-style-name}"/>
  855.                     </w:rPr>
  856.                     <xsl:choose>
  857.                         <xsl:when test="../../text:endnote-citation/@text:label">
  858.                             <w:t>
  859.                                 <xsl:value-of select="../../text:endnote-citation/@text:label"/>
  860.                             </w:t>
  861.                         </xsl:when>
  862.                         <xsl:otherwise>
  863.                             <w:endnoteRef/>
  864.                         </xsl:otherwise>
  865.                     </xsl:choose>
  866.                 </w:r>
  867.                 <w:r>
  868.                     <w:tab/>
  869.                 </w:r>
  870.             </xsl:if>
  871.             <!-- newly added the endnote , footnote templates -->
  872.             <xsl:if test="../../@text:note-class='endnote'  and not(preceding-sibling::*)">
  873.                 <xsl:message>
  874.                     <xsl:value-of select=" 'enter into ext:note-class= endnote' "/>
  875.                 </xsl:message>
  876.                 <w:r>
  877.                     <w:rPr>
  878.                         <w:rStyle w:val="Endnote_20_Symbol"/>
  879.                     </w:rPr>
  880.                     <xsl:choose>
  881.                         <xsl:when test="../../text:note-citation/@text:label">
  882.                             <w:t>
  883.                                 <xsl:value-of select="../../text:note-citation/@text:label"/>
  884.                             </w:t>
  885.                         </xsl:when>
  886.                         <xsl:otherwise>
  887.                             <w:footnoteRef/>
  888.                         </xsl:otherwise>
  889.                     </xsl:choose>
  890.                 </w:r>
  891.                 <w:r>
  892.                     <w:tab/>
  893.                 </w:r>
  894.             </xsl:if>
  895.             <xsl:if test="../../@text:note-class='footnote'  and not(preceding-sibling::*)">
  896.                 <xsl:message>
  897.                     <xsl:value-of select=" 'enter into ext:note-class= footnote' "/>
  898.                 </xsl:message>
  899.                 <w:r>
  900.                     <w:rPr>
  901.                         <w:rStyle w:val="Footnote_20_Symbol"/>
  902.                     </w:rPr>
  903.                     <xsl:choose>
  904.                         <xsl:when test="../../text:note-citation/@text:label">
  905.                             <w:t>
  906.                                 <xsl:value-of select="../../text:note-citation/@text:label"/>
  907.                             </w:t>
  908.                         </xsl:when>
  909.                         <xsl:otherwise>
  910.                             <w:footnoteRef/>
  911.                         </xsl:otherwise>
  912.                     </xsl:choose>
  913.                 </w:r>
  914.                 <w:r>
  915.                     <w:tab/>
  916.                 </w:r>
  917.             </xsl:if>
  918.             <!-- apply inline-text-elements, many many many ... :( glu -->
  919.             <xsl:apply-templates select="text:a | text:span | text() | text:hidden-text | text:line-break | text:tab-stop 
  920.              | text:s | text:note  | draw:*
  921.              | text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date | text:time 
  922.              | text:author-name | text:author-initials | text:chapter | text:file-name | text:sender-company 
  923.              | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
  924.              | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title | text:sender-position 
  925.              | text:sender-phone-private | text:sender-phone-work | text:sender-email | text:sender-fax
  926.              | text:sender-state-or-province | text:word-count | text:paragraph-count | text:character-count
  927.              | text:table-count | text:image-count | text:object-count | text:template-name | text:description 
  928.              | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
  929.              | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date 
  930.              | text:user-defined | text:printed-by | text:hidden-paragraph  | text:placeholder | text:drop-down 
  931.              | text:conditional-text  | text:text-input | text:execute-macro | text:variable-set | text:variable-input
  932.              | text:user-field-input | text:variable-get | text:user-field-get | text:sequence | text:page-variable-set 
  933.              | text:page-variable-get | text:table-formula | text:database-display | text:database-next
  934.              | text:database-select | text:database-row-number | text:database-name | text:reference-ref 
  935.              | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref | text:expression
  936.              | text:measure | text:dde-connection | text:sheet-name | text:bibliography-mark | text:script
  937.              | text:page-continuation | office:annotation | text:bookmark-start | text:bookmark-end | text:bookmark
  938.  "/>
  939.             <!-- comment out the following line to replace the text:footnote , text:endnote with text:note in OASIS format -->
  940.             <!--xsl:apply-templates select="text:a | text:span | text() | text:hidden-text | text:line-break | text:tab-stop 
  941.              | text:s | text:footnote | text:endnote | draw:*
  942.              | text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date | text:time 
  943.              | text:author-name | text:author-initials | text:chapter | text:file-name | text:sender-company 
  944.              | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
  945.              | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title | text:sender-position 
  946.              | text:sender-phone-private | text:sender-phone-work | text:sender-email | text:sender-fax
  947.              | text:sender-state-or-province | text:word-count | text:paragraph-count | text:character-count
  948.              | text:table-count | text:image-count | text:object-count | text:template-name | text:description 
  949.              | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
  950.              | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date 
  951.              | text:user-defined | text:printed-by | text:hidden-paragraph  | text:placeholder | text:drop-down 
  952.              | text:conditional-text  | text:text-input | text:execute-macro | text:variable-set | text:variable-input
  953.              | text:user-field-input | text:variable-get | text:user-field-get | text:sequence | text:page-variable-set 
  954.              | text:page-variable-get | text:table-formula | text:database-display | text:database-next
  955.              | text:database-select | text:database-row-number | text:database-name | text:reference-ref 
  956.              | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref | text:expression
  957.              | text:measure | text:dde-connection | text:sheet-name | text:bibliography-mark | text:script
  958.              | text:page-continuation | office:annotation | text:bookmark-start | text:bookmark-end | text:bookmark
  959.  "/-->
  960.             <xsl:if test="$style/@fo:break-after">
  961.                 <w:r>
  962.                     <w:br w:type="{$style/@fo:break-after}"/>
  963.                 </w:r>
  964.             </xsl:if>
  965.         </w:p>
  966.     </xsl:template>
  967.     <xsl:template match="text:span">
  968.         <!-- apply inline-text-elements, many many many ... :( glu -->
  969.         <xsl:apply-templates select="text:a | text() | text:hidden-text | text:line-break | text:tab-stop | text:s
  970.              | text:note
  971.              | text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date | text:time 
  972.              | text:author-name | text:author-initials | text:chapter | text:file-name | text:sender-company 
  973.              | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
  974.              | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title | text:sender-position 
  975.              | text:sender-phone-private | text:sender-phone-work | text:sender-email | text:sender-fax
  976.              | text:sender-state-or-province | text:word-count | text:paragraph-count | text:character-count
  977.              | text:table-count | text:image-count | text:object-count | text:template-name | text:description 
  978.              | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
  979.              | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date 
  980.              | text:user-defined | text:printed-by | text:hidden-paragraph  | text:placeholder | text:drop-down 
  981.              | text:conditional-text  | text:text-input | text:execute-macro | text:variable-set | text:variable-input
  982.              | text:user-field-input | text:variable-get | text:user-field-get | text:sequence | text:page-variable-set 
  983.              | text:page-variable-get | text:table-formula | text:database-display | text:database-next
  984.              | text:database-select | text:database-row-number | text:database-name | text:reference-ref 
  985.              | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref | text:expression
  986.              | text:measure | text:dde-connection | text:sheet-name | text:bibliography-mark | text:script 
  987.              | text:page-continuation | office:annotation | text:bookmark-start | text:bookmark-end | text:bookmark
  988. "/>
  989.         <!-- comment out the following line to replace the text:footnote , text:endnote with text:note in OASIS format -->
  990.         <!-- xsl:apply-templates select="text:a | text() | text:hidden-text | text:line-break | text:tab-stop | text:s
  991.              | text:footnote | text:endnote
  992.              | text:page-number | text:page-count | text:subject | text:initial-creator | text:title | text:date | text:time 
  993.              | text:author-name | text:author-initials | text:chapter | text:file-name | text:sender-company 
  994.              | text:sender-firstname | text:sender-lastname | text:sender-initials | text:sender-street
  995.              | text:sender-country | text:sender-postal-code | text:sender-city | text:sender-title | text:sender-position 
  996.              | text:sender-phone-private | text:sender-phone-work | text:sender-email | text:sender-fax
  997.              | text:sender-state-or-province | text:word-count | text:paragraph-count | text:character-count
  998.              | text:table-count | text:image-count | text:object-count | text:template-name | text:description 
  999.              | text:creation-time | text:creation-date | text:editing-cycles | text:editing-duration | text:keywords
  1000.              | text:print-time | text:print-date | text:creator | text:modification-time | text:modification-date 
  1001.              | text:user-defined | text:printed-by | text:hidden-paragraph  | text:placeholder | text:drop-down 
  1002.              | text:conditional-text  | text:text-input | text:execute-macro | text:variable-set | text:variable-input
  1003.              | text:user-field-input | text:variable-get | text:user-field-get | text:sequence | text:page-variable-set 
  1004.              | text:page-variable-get | text:table-formula | text:database-display | text:database-next
  1005.              | text:database-select | text:database-row-number | text:database-name | text:reference-ref 
  1006.              | text:bookmark-ref | text:footnote-ref  | text:endnote-ref | text:sequence-ref | text:expression
  1007.              | text:measure | text:dde-connection | text:sheet-name | text:bibliography-mark | text:script 
  1008.              | text:page-continuation | office:annotation | text:bookmark-start | text:bookmark-end | text:bookmark
  1009. "/-->
  1010.     </xsl:template>
  1011.     <xsl:template match="text()">
  1012.         <xsl:if test="string-length(normalize-space(.)) > 0">
  1013.             <w:r>
  1014.                 <xsl:if test="parent::text:span">
  1015.                     <w:rPr>
  1016.                         <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
  1017.                     </w:rPr>
  1018.                 </xsl:if>
  1019.                 <w:t>
  1020.                     <xsl:value-of select="."/>
  1021.                 </w:t>
  1022.             </w:r>
  1023.         </xsl:if>
  1024.     </xsl:template>
  1025.     <xsl:template match="text:hidden-text">
  1026.         <w:r>
  1027.             <w:rPr>
  1028.                 <xsl:if test="parent::text:span">
  1029.                     <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
  1030.                 </xsl:if>
  1031.                 <w:vanish/>
  1032.             </w:rPr>
  1033.             <w:t>
  1034.                 <xsl:value-of select="@text:string-value"/>
  1035.             </w:t>
  1036.         </w:r>
  1037.     </xsl:template>
  1038.     <xsl:template match="text:line-break">
  1039.         <w:r>
  1040.             <xsl:if test="parent::text:span">
  1041.                 <w:rPr>
  1042.                     <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
  1043.                 </w:rPr>
  1044.             </xsl:if>
  1045.             <w:br w:type="text-wrapping" w:clear="all"/>
  1046.         </w:r>
  1047.     </xsl:template>
  1048.     <xsl:template match="text:tab-stop">
  1049.         <w:r>
  1050.             <xsl:if test="parent::text:span">
  1051.                 <w:rPr>
  1052.                     <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
  1053.                 </w:rPr>
  1054.             </xsl:if>
  1055.             <w:tab/>
  1056.         </w:r>
  1057.     </xsl:template>
  1058.     <xsl:template match="text:s">
  1059.         <w:r>
  1060.             <xsl:if test="parent::text:span">
  1061.                 <w:rPr>
  1062.                     <w:rStyle w:val="{parent::text:span/@text:style-name}"/>
  1063.                 </w:rPr>
  1064.             </xsl:if>
  1065.             <w:t>
  1066.                 <xsl:if test="@text:c">
  1067.                     <xsl:call-template name="add-space">
  1068.                         <xsl:with-param name="number" select="@text:c"/>
  1069.                     </xsl:call-template>
  1070.                 </xsl:if>
  1071.                 <xsl:text> </xsl:text>
  1072.             </w:t>
  1073.         </w:r>
  1074.     </xsl:template>
  1075.     <xsl:template name="add-space">
  1076.         <xsl:param name="number"/>
  1077.         <xsl:if test="$number > 1">
  1078.             <xsl:call-template name="add-space">
  1079.                 <xsl:with-param name="number" select="$number - 1"/>
  1080.             </xsl:call-template>
  1081.             <xsl:text> </xsl:text>
  1082.         </xsl:if>
  1083.     </xsl:template>
  1084.     <xsl:template match="text:footnote">
  1085.         <w:r>
  1086.             <w:rPr>
  1087.                 <w:rStyle w:val="{/office:document/office:styles/text:footnotes-configuration/@text:citation-body-style-name}"/>
  1088.             </w:rPr>
  1089.             <xsl:apply-templates select="text:footnote-body"/>
  1090.         </w:r>
  1091.     </xsl:template>
  1092.     <xsl:template match="text:footnote-body">
  1093.         <w:footnote>
  1094.             <xsl:if test="../text:footnote-citation/@text:label">
  1095.                 <xsl:attribute name="w:suppressRef">on</xsl:attribute>
  1096.             </xsl:if>
  1097.             <xsl:apply-templates select="text:h | text:p | text:ordered-list | text:unordered-list | text:list"/>
  1098.         </w:footnote>
  1099.     </xsl:template>
  1100.     <xsl:template match="text:endnote">
  1101.         <w:r>
  1102.             <w:rPr>
  1103.                 <w:rStyle w:val="{/office:document/office:styles/text:endnotes-configuration/@text:citation-body-style-name}"/>
  1104.             </w:rPr>
  1105.             <xsl:apply-templates select="text:endnote-body"/>
  1106.         </w:r>
  1107.     </xsl:template>
  1108.     <xsl:template match="text:endnote-body">
  1109.         <w:endnote>
  1110.             <xsl:if test="../text:endnote-citation/@text:label">
  1111.                 <xsl:attribute name="w:suppressRef">on</xsl:attribute>
  1112.             </xsl:if>
  1113.             <xsl:apply-templates select="text:h | text:p | text:ordered-list | text:unordered-list | text:list"/>
  1114.         </w:endnote>
  1115.     </xsl:template>
  1116.     <xsl:template match="text:bookmark-start">
  1117.         <xsl:variable name="bookmark-id">
  1118.             <xsl:number from="/office:document/office:body" count="text:bookmark | text:bookmark-start" level="any" format="1"/>
  1119.         </xsl:variable>
  1120.         <aml:annotation aml:id="{$bookmark-id}" w:type="Word.Bookmark.Start" w:name="{@text:name}"/>
  1121.     </xsl:template>
  1122.     <xsl:template match="text:bookmark-end">
  1123.         <xsl:variable name="bookmark-id">
  1124.             <xsl:number from="/office:document/office:body" count="text:bookmark | text:bookmark-start" level="any" format="1"/>
  1125.         </xsl:variable>
  1126.         <aml:annotation aml:id="{$bookmark-id}" w:type="Word.Bookmark.End"/>
  1127.     </xsl:template>
  1128.     <xsl:template match="text:bookmark">
  1129.         <xsl:variable name="bookmark-id">
  1130.             <xsl:number from="/office:document/office:body" count="text:bookmark | text:bookmark-start" level="any" format="1"/>
  1131.         </xsl:variable>
  1132.         <aml:annotation aml:id="{$bookmark-id}" w:type="Word.Bookmark.Start" w:name="{@text:name}"/>
  1133.         <aml:annotation aml:id="{$bookmark-id}" w:type="Word.Bookmark.End"/>
  1134.     </xsl:template>
  1135.     <!-- newly added the endnote , footnote templates -->
  1136.     <xsl:template match="text:note">
  1137.         <xsl:choose>
  1138.             <xsl:when test="@text:note-class = 'endnote' ">
  1139.                 <w:r>
  1140.                     <w:rPr>
  1141.                         <w:rStyle w:val="Endnote"/>
  1142.                     </w:rPr>
  1143.                     <xsl:apply-templates select="text:note-body"/>
  1144.                 </w:r>
  1145.             </xsl:when>
  1146.             <xsl:when test="@text:note-class = 'footnote' ">
  1147.                 <w:r>
  1148.                     <w:rPr>
  1149.                         <w:rStyle w:val="Footnote"/>
  1150.                     </w:rPr>
  1151.                     <xsl:apply-templates select="text:note-body"/>
  1152.                 </w:r>
  1153.             </xsl:when>
  1154.         </xsl:choose>
  1155.     </xsl:template>
  1156.     <xsl:template match="text:note-body">
  1157.         <xsl:choose>
  1158.             <xsl:when test="../@text:note-class='endnote' ">
  1159.                 <w:endnote>
  1160.                     <xsl:if test="../text:note-citation/@text:label">
  1161.                         <xsl:attribute name="w:suppressRef">on</xsl:attribute>
  1162.                     </xsl:if>
  1163.                     <xsl:apply-templates select="text:h | text:p | text:ordered-list | text:unordered-list | text:list"/>
  1164.                 </w:endnote>
  1165.             </xsl:when>
  1166.             <xsl:when test="../@text:note-class='footnote' ">
  1167.                 <w:footnote>
  1168.                     <xsl:if test="../text:note-citation/@text:label">
  1169.                         <xsl:attribute name="w:suppressRef">on</xsl:attribute>
  1170.                     </xsl:if>
  1171.                     <xsl:apply-templates select="text:h | text:p | text:ordered-list | text:unordered-list | text:list"/>
  1172.                 </w:footnote>
  1173.             </xsl:when>
  1174.         </xsl:choose>
  1175.     </xsl:template>
  1176. </xsl:stylesheet>
  1177.